<template>
  <div class="toTop">
    <!-- 回顶 -->
    <el-backtop @mouseover.native="changeT" @mouseleave.native="resizeT">
      <div class="totop" ref="toTop">回到顶部</div>
      <i class="el-icon-caret-top" ref="triangle"></i>
    </el-backtop>
  </div>
</template>

<script>
export default {
  methods: {
    changeT() {
      this.$refs.toTop.style.display = 'block'
      this.$refs.triangle.style.display = 'none'
    },
    resizeT() {
      this.$refs.toTop.style.display = 'none'
      this.$refs.triangle.style.display = 'block'
    }
  }
}
</script>

<style lang="less" scoped>
.totop {
  padding: 6px;
  background-color: #f2f5f6;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.12);
  text-align: center;
  line-height: 20px;
  color: #f90;
  display: none;
  font-size: 14px;
}
</style>